package com.baimawangzi.recovery.servlet.goods;

import com.baimawangzi.recovery.bean.Cate;
import com.baimawangzi.recovery.bean.User;
import com.baimawangzi.recovery.service.impl.CateServiceImpl;
import com.baimawangzi.recovery.service.impl.UserServiveImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

//为update提供数据
@WebServlet("/gooodsupdatedata.do")
public class GoodsUpdateServletData extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        CateServiceImpl cateService = new CateServiceImpl();
        UserServiveImpl userServive = new UserServiveImpl();
        //查数据
        List<Cate> cates = cateService.getAll();
        List<User> users = userServive.getAll();
        //用于调试
        for (Cate cate : cates) {

            System.out.println(cate);
        }
        req.setAttribute("cates",cates);
        req.setAttribute("users",users);
        req.getRequestDispatcher("goods_add.jsp").forward(req,resp);
    }
}
